package com.cqc.jdk8.Jutil.concurrent.locks.ReentrantLock.demo1;

import java.util.concurrent.TimeUnit;
/**
 * 在使用  ReentrantLock 前，
 * 先回想下 synchronized 的用法
 */
public class ThreadTest {

    public static void main(String[] args) throws InterruptedException {
        Counter counter = new Counter();
        for (int i = 0; i < 10; i++) {
            new Thread(() -> {
                counter.add();
            }).start();

        }
        TimeUnit.SECONDS.sleep(1);
        System.out.println(counter.getCount());
    }
}
